<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="gmms" uri="/gmms-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<c:choose>
<c:when test="${loadData==null}">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>需求申请管理</title>
<jsp:include page="../../pages/head.jsp" />
<link rel="stylesheet" type="text/css" media="screen" href="<%=path %>/js/jquery.combogrid/resources/css/smoothness/jquery-ui-1.10.1.custom.css"/>
<script type="text/javascript" src="<%=path %>/js/jquery.combogrid/resources/jquery/jquery-ui-1.10.1.custom.min.js"></script>
<link rel="stylesheet" type="text/css" media="screen" href="<%=path %>/js/jquery.combogrid/resources/css/smoothness/jquery.ui.combogrid.css"/>
<script type="text/javascript" src="<%=path %>/js/jquery.combogrid/resources/plugin/jquery.ui.combogrid-1.6.3.js"></script>
<script language="javascript">
function toSubmit(keyId){
	xbox.confirm("提交后表单将无法进行更改操作,确认吗?", function (result) {
        if (result) {
				  $.ajax({
							url			:"<%=path%>/demindapply/demindapplyAjax_toSubmit_msgAction.action",
							type 		: "POST",
							dataType 	: "json",
							data		: {
								"demindApplyId" : keyId
							},
							success 	: function(data) {
								if(data=="数据提交成功")
									j_loadData($("#currentPage").val());
								else{
									xbox.alert(data,function(){
										j_loadData($("#currentPage").val());	
									});
								}
							},
							error		:function(){
								xbox.alert("数据正在提交，请稍候，或检查您的网络环境,确保其连接正常！");
							}
						});
		    }
		    }, {
        title: '系统提示',
        value: '确定'
    });
}

function del(keyId){
	xbox.confirm("您正在执行删除操作,确认吗?", function (result) {
        if (result) {
        	$.ajax({
				url			:"<%=path%>/demindapply/demindapplyAjax_delete_msgAction.action",
				type 		: "POST",
				dataType 	: "json",
				data		: {
					"demindApplyId" : keyId
				},
				success 	: function(data) {
					if(data=="数据删除成功")
						j_loadData($("#currentPage").val());
					else{
						xbox.alert(data,function(){
							j_loadData($("#currentPage").val());	
						});
					}
				},
				error		:function(){
					xbox.alert("数据正在提交，请稍候，或检查您的网络环境,确保其连接正常！");
				}
			});
        }
    }, {
        title: '系统提示',
        value: '确定'
    });
}

function toAdd(){
	j_goUrl("<%=path%>/demindapply/demindapply_toAdd_addAction.action",1);
}

function toEdit(keyId){
	j_goUrl("<%=path%>/demindapply/demindapply_toEdit_editAction.action?demindApplyId="+keyId,$("#currentPage").val());
}

function toShow(keyId){
	openModelWindow("查看需求申请","<%=path%>/demindapply/demindapply_toShow_showAction.action?demindApplyId="+keyId);
}

$(function(){
	$( "#clientName" ).combogrid({
		url: '<%=path%>/client/clientAjax_query4AutoComplete_resourceAction.action?t='+t,
		debug:false,
    	getParams: function(){ var areaId = $("#areaId").val(); return (areaId=="" ? "":"&areaId="+areaId)},
		colModel: [{'columnName':'clientId','width':'15','label':'编号'}, {'columnName':'clientName','width':'40','label':'客户名称'},{'columnName':'areaName','width':'40','label':'办事处'}],
		select: function( event, ui ) {
			$(this).val(ui.item.clientName);
			return false;
		}
	});
});

</script>
</head>

<body>
<div class="info_right_main">
<form action="<%=path%>/demindapply/demindapply_queryList_listAction.action" method="post" id="refreshForm" name="refreshForm">
	<input type="hidden" id="currentPage" name="currentPage" value="${currentPage}"/>
	<input type="hidden" id="areaId" name="areaId" value="${areaId}"/>
    <div class="info_right_tab">
    <c:if test='${fn:contains(authorityCode,",0001,") or fn:contains(authorityCode,",0005,")}'>
    		<table cellpadding="3" width="100%" cellspacing="0" border="0" style="margin-top:30px;padding-left:10px;">
				<tr>
					<td width="70" align="right">需求编号：</td>
					<td width="160"><input type="text" isInt="需求编号" notFill="1" name="searchId" value="${searchId}" class="info_right_input" /></td>
					<td width="70" align="right">需求标题：</td>
					<td width="160"><input type="text" name="demindApplyTitle" value="${demindApplyTitle}" class="info_right_input"/></td>
					<td width="70" align="right">项目名称：</td>
					<td colspan="2"><input type="text" id="projectName" name="projectName" value="${projectName}" class="info_right_input"/></td>
				</tr>
				<tr>
					<td align="right">客户名称：</td>
					<td><input type="text" id="clientName" name="clientName" value="${clientName}" class="info_right_input" /></td>
					<td align="right">需求级别：</td>
					<td>
						<select name="demindLevelId" style='width:150px'>
							<option value="">全部</option>
							<c:forEach items="${listDemindLevel}" var="o">
				          		<option value="${o.demindLevelId}" <c:if test="${o.demindLevelId eq demindLevelId}">selected="selected"</c:if>>${o.demindLevelName}</option>
				          	</c:forEach>
						</select>
					</td>
					<td align="right">需求类别：</td>
					<td width="170">
						<select name="demindTypeId" style='width:150px'>
							<option value="">全部</option>
							<c:forEach items="${listDemindType}" var="o">
				          		<option value="${o.demindTypeId}" <c:if test="${o.demindTypeId eq demindTypeId}">selected="selected"</c:if>>${o.demindTypeName}</option>
				          	</c:forEach>
						</select>
					</td>
					<td><input class="btn" onclick="j_search(1)" id="btnSearch" type="button" value="查询" /> 
                		<input class="btn" onclick="j_search(1,true)" type="button" value="重置" /></td>
				</tr>
			</table>	
		</div>
	</c:if>
	</div>
</form>
<div class="info_right_ctrl">
	<c:if test='${fn:contains(authorityCode,",0001,") or fn:contains(authorityCode,",0002,")}'>
		<input class="btn" onclick="toAdd();" type="button" value="添加需求申请" />
	</c:if>
    <input class="btn" type="button" onclick="j_search(1,true);" value="更新列表" />
    <span style="font-size:13px;padding-top:15px;float:right;padding-right:30p帮助rsor帮助inter;" onclick="operationManual(${currentMenuId})">
    	<img src="<%=path %>/images/help.png" title="操作手册" />操作手册
    </span>
</div>
        
        
<div class="info_right_main">
	<div id="gridHead">
		<table width="100%" border="0" cellspacing="0" cellpadding="0" style="TABLE-LAYOUT:fixed;">
		 	<tr height="35">
	         <td width="60" align="center"><strong>序号</strong></td>
	         <td width="80" align="center"><strong>需求编号</strong></td>
	         <td width="150" align="center"><strong>需求标题</strong></td>
	         <td width="100" align="center"><strong>所属项目</strong></td>
	         <td width="100" align="center"><strong>所属办事处</strong></td>
	         <td width="100" align="center"><strong>所属客户</strong></td>
	         <td width="100" align="center"><strong>需求级别</strong></td>
	         <td width="100" align="center"><strong>需求类别</strong></td>
	         <td width="80" align="center"><strong>申请人</strong></td>
	         <td width="100" align="center"><strong>申请负责人</strong></td>
	         <td width="100" align="center"><strong>解决负责人</strong></td>
	         <td width="150" align="center"><strong>创建时间</strong></td>
	         <td width="150" align="center"><strong>提交时间</strong></td>
	         <td width="150" align="center"><strong>期望完成时间</strong></td>
	         <td width="150" align="center"><strong>审核时间</strong></td>
	         <td width="80" align="center"><strong>操作员</strong></td>
	         <td width="80" align="center"><strong>当前角色</strong></td>
	         <td width="80" align="center"><strong>审核状态</strong></td>
	         <td width="150" align="center"><strong>最后回馈时间</strong></td>
	         <td width="100" align="center"><strong>最后回馈人</strong></td>
	         <td width="80" align="center"><strong>回馈数量</strong></td>
	         <td width="120" align="center"><strong>操作</strong></td>
	       </tr>
		</table>
	</div>
	<div style="overflow:auto;display:none;" id="divGrid">
	</div>
	<table border="0" cellspacing="0" cellpadding="0" width="100%" id="tablePager"></table>
</div>
  
</div>
</body>
</html>

</c:when>
<c:otherwise>
<table id="gridTable" width="100%" border="0" cellspacing="0" cellpadding="0">
	       <c:forEach items="${list}" var="demindApply" varStatus="status">
				<c:if test="${demindApply.auditState eq 0}"><tr align='center' bgcolor="#FFFFFF" onMouseMove="javascript:this.bgColor='#f1f1f1';" onMouseOut="javascript:this.bgColor='#FFFFFF';" height="30" ></c:if>
				<c:if test="${demindApply.auditState eq 1}"><tr align='center' bgcolor="#F0E68C" onMouseMove="javascript:this.bgColor='#f1f1f1';" onMouseOut="javascript:this.bgColor='#F0E68C';" height="30" ></c:if>
				<c:if test="${demindApply.auditState eq 999}"><tr align='center' bgcolor="#90EE90" onMouseMove="javascript:this.bgColor='#f1f1f1';" onMouseOut="javascript:this.bgColor='#90EE90';" height="30" ></c:if>
					<td>${status.index+1}</td>
					<td>${demindApply.demindApplyId}</td>
					<td>${demindApply.demindApplyTitle}</td>
					<td>${demindApply.project.projectName}</td>
					<td>${demindApply.area.areaName}</td>
					<td>${demindApply.client.clientName}</td>
					<td>${demindApply.demindLevel.demindLevelName}</td>
					<td>${demindApply.demindType.demindTypeName}</td>
					<td>${demindApply.demindApplyUser.realName}</td>
					<td>${demindApply.demindApplyDutyuser.realName}</td>
					<td>${demindApply.demindSolveDutyuser.realName}</td>
					<td><fmt:formatDate value="${demindApply.recordCreateTime}" pattern="yyyy-MM-dd HH:mm"/></td>
					<td><fmt:formatDate value="${demindApply.demindApplyTime}" pattern="yyyy-MM-dd HH:mm"/></td>
					<td><fmt:formatDate value="${demindApply.needCompleteTime}" pattern="yyyy-MM-dd HH:mm"/></td>
					<td><fmt:formatDate value="${demindApply.auditTime}" pattern="yyyy-MM-dd HH:mm"/></td>
					<td>${demindApply.user.realName}</td>
					<td>${demindApply.currentRole.roleName}</td>
					<td>
						<c:if test="${demindApply.auditState==0}">未提交</c:if>
						<c:if test="${demindApply.auditState==1}">正在审核</c:if>
						<c:if test="${demindApply.auditState==999}"><span style="color:green;">已审核</span></c:if>
					</td>
					<td><fmt:formatDate value="${demindApply.lastReplyTime}" pattern="yyyy-MM-dd HH:mm"/></td>
					<td>${demindApply.lastReplyUser.realName}</td>
					<td>${demindApply.replySum}</td>
					<td>
						<span style="width:140px;"><input class="btn" onclick="toShow(${demindApply.demindApplyId});" type="button" value="详情" /></span>
						<c:if test="${demindApply.auditState eq 0}">
							<c:if test='${fn:contains(authorityCode,",0001,") or fn:contains(authorityCode,",0008,")}'>
								<span><input class="btn" onclick="toSubmit(${demindApply.demindApplyId});" type="button" value="提交" /></span>
							</c:if>
							<c:if test='${fn:contains(authorityCode,",0001,") or fn:contains(authorityCode,",0003,")}'>
								<span style="width:140px;"><input class="btn" onclick="toEdit(${demindApply.demindApplyId});" type="button" value="编辑" /></span>
							</c:if>
							<c:if test='${fn:contains(authorityCode,",0001,") or fn:contains(authorityCode,",0004,")}'>
								<input class="btn" onclick="del(${demindApply.demindApplyId});" type="button" value="删除" />
							</c:if>
						</c:if>
					</td>
				</tr>
			</c:forEach>
			<tr align="right" bgcolor="#f1f1f1">
				<td height="30" colspan="9" align="right">
				 <!-- 分页 -->
				 <gmms:pages currentPage="%{currentPage}" totalPage="%{totalPage}" />
				</td>
			</tr>
     </table>
</c:otherwise>
</c:choose>
